package com.ruoyi.project.platform.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import com.ruoyi.framework.security.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.platform.mapper.PltUserProjectMapper;
import com.ruoyi.project.platform.domain.PltUserProject;
import com.ruoyi.project.platform.service.IPltUserProjectService;

/**
 * 项目Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-09-16
 */
@Service
public class PltUserProjectServiceImpl implements IPltUserProjectService 
{
    @Autowired
    private PltUserProjectMapper pltUserProjectMapper;

    /**
     * 查询项目
     * 
     * @param projectId 项目ID
     * @return 项目
     */
    @Override
    public PltUserProject selectPltUserProjectById(Long projectId)
    {
        return pltUserProjectMapper.selectPltUserProjectById(projectId);
    }

    /**
     * 查询项目列表
     * 
     * @param pltUserProject 项目
     * @return 项目
     */
    @Override
    @DataScope(userAlias = "u")
    public List<PltUserProject> selectPltUserProjectList(PltUserProject pltUserProject)
    {
        return pltUserProjectMapper.selectPltUserProjectList(pltUserProject);
    }

    /**
     * 新增项目
     * 
     * @param pltUserProject 项目
     * @return 结果
     */
    @Override
    public int insertPltUserProject(PltUserProject pltUserProject)
    {
        LoginUser currentUser = SecurityUtils.getLoginUser();
        pltUserProject.setUserId(currentUser.getUser().getUserId());
        pltUserProject.setUserName(currentUser.getUser().getUserName());
        return pltUserProjectMapper.insertPltUserProject(pltUserProject);
    }

    /**
     * 修改项目
     * 
     * @param pltUserProject 项目
     * @return 结果
     */
    @Override
    public int updatePltUserProject(PltUserProject pltUserProject)
    {
        return pltUserProjectMapper.updatePltUserProject(pltUserProject);
    }

    /**
     * 批量删除项目
     * 
     * @param projectIds 需要删除的项目ID
     * @return 结果
     */
    @Override
    public int deletePltUserProjectByIds(Long[] projectIds)
    {
        return pltUserProjectMapper.deletePltUserProjectByIds(projectIds);
    }

    /**
     * 删除项目信息
     * 
     * @param projectId 项目ID
     * @return 结果
     */
    @Override
    public int deletePltUserProjectById(Long projectId)
    {
        return pltUserProjectMapper.deletePltUserProjectById(projectId);
    }
}
